﻿// <copyright file="ProductIconHelperTest.cs" company="Snowman Consulting">
//     Copyright (c) 2009 Snowman Consulting. All rights reserved.
// </copyright>

namespace SnowmanConsulting.ProductKeyManager.Test
{
    using System;
    using System.Linq;
    using System.Windows.Media.Imaging;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using SnowmanConsulting.ProductKeyManager.Data;

    /// <summary>
    /// ProductIconHelperTest test class
    /// </summary>
    [TestClass]
    public class ProductIconHelperTest
    {
        /// <summary>
        /// Test context instance
        /// </summary>
        private TestContext testContextInstance;

        /// <summary>
        /// Initializes a new instance of the <see cref="ProductIconHelperTest"/> class.
        /// </summary>
        public ProductIconHelperTest()
        {
            // TODO: Add constructor logic here
        }

        /// <summary>
        /// Gets or sets the test context which provides
        /// information about and functionality for the current test run.
        /// </summary>
        public TestContext TestContext
        {
            get
            {
                return this.testContextInstance;
            }

            set
            {
                this.testContextInstance = value;
            }
        }

        #region Additional test attributes
        // You can use the following additional attributes as you write your tests:
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        #endregion

        /// <summary>
        /// Generics the application icon test.
        /// </summary>
        [TestMethod]
        public void GenericApplicationIconTest()
        {
            ProductIcon icon = ProductIconHelper.GenericApplicationIcon;

            Assert.AreEqual("../Icons/Generic_Application.ico", icon.IconUrl, true);
        }

        /// <summary>
        /// Generics the device icon test.
        /// </summary>
        [TestMethod]
        public void GenericDeviceIconTest()
        {
            ProductIcon icon = ProductIconHelper.GenericDeviceIcon;

            Assert.AreEqual("../Icons/Generic_Device.ico", icon.IconUrl, true);
        }

        /// <summary>
        /// Generics the document icon test.
        /// </summary>
        [TestMethod]
        public void GenericDocumentIconTest()
        {
            ProductIcon icon = ProductIconHelper.GenericDocumentIcon;

            Assert.AreEqual("../Icons/Generic_Document.ico", icon.IconUrl, true);
        }

        /// <summary>
        /// Loads the default icons test.
        /// </summary>
        [TestMethod]
        public void LoadDefaultIconsTest()
        {
            ProductIconCollection icons = new ProductIconCollection();
            ProductIconHelper.LoadDefaultIcons(icons);

            Assert.IsNotNull(from i in icons where i == ProductIconHelper.GenericApplicationIcon select i);
            Assert.IsNotNull(from i in icons where i == ProductIconHelper.GenericDeviceIcon select i);
            Assert.IsNotNull(from i in icons where i == ProductIconHelper.GenericDocumentIcon select i);
        }

        /// <summary>
        /// Loads the image test.
        /// </summary>
        [TestMethod]
        public void LoadImageTest()
        {
            BitmapImage image = ProductIconHelper.LoadImage(new Uri("cmd.ico", UriKind.Relative));

            Assert.IsNotNull(image);
            Assert.AreEqual("cmd.ico", image.UriSource.ToString(), true);
        }
    }
}
